<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Bootstrap Admin</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
</head>

<include file="common/key"/>
<body class="">
<!--<![endif]-->
<include file="common/nav"/>
<include file="common/left"/>

<div class="content">

    <div class="header">
        <h1 class="page-title">添加用户</h1>
    </div>

    <ul class="breadcrumb">
        <li><a href="index.html">首页</a> <span class="divider">/</span></li>
        <li><a href="users.html">用户管理</a> <span class="divider">/</span></li>
        <li class="active">添加用户</li>
    </ul>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="well">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <form id="tab" action="/Admin/User/Add" method="post">
                            <label>用户名</label>
                            <input type="text" class="input-xlarge" name="user_name"/>
                            <label>职业</label>
                            <input type="text" class="input-xlarge" name="user_zhi">
                            <label>描述</label>
                            <textarea rows="3" class="input-xlarge" name="user_decrbit"></textarea>
                            <label></label>
                            <button class="btn btn-primary" type="submit"><i class="icon-save"></i> 保存</button><span id="tips" style="color:#ff231e;margin-left:12px;"></span>
                        </form>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function getspanval(i) {
        $('#tips').html(i);
    }
    $('#tab').submit(function () {
        var user_name = $('[name="user_name"]').val();
        var user_zhi = $('[name="user_zhi"]').val();
        var user_decrbit = $('[name="user_decrbit"]').val();
        getspanval('');
        if (user_name == '') {
            getspanval('请输入用户名');
            return false;
        }
        if (user_zhi == '') {
            getspanval('请输入职业');
            return false;
        }
        if (user_decrbit == '') {
            getspanval('请输入描述');
            return false;
        }
        $.ajax({
            url:'/Admin/User/add',
            type:'post',
            dataType:'json',
            data:{user_name:user_name, user_zhi:user_zhi, user_decrbit:user_decrbit},
            success: function(){
                alert('添加成功');
               setTimeout(function () {
                    window.location.href='/Admin/User/index';
               });
            },
            error:function() {
                getspanval('系统异常');
                return false;
            }
        });
        return false;
    });
</script>

</body>
</html>







